package com.zr.service.impl;

import com.zr.dao.UserDao;
import com.zr.dao.impl.UserDaoImpl;
import com.zr.service.UserService;
import com.zr.utils.Md5Util;
import com.zr.vo.User;

import java.sql.SQLException;
import java.util.List;

public class UserServiceImpl implements UserService {

    private UserDao userDao = new UserDaoImpl();

    @Override
    public User login(String userId, String password) {
        return userDao.login(userId, password);
    }

    @Override
    public List<User> list(User user) {
        return userDao.list(user);
    }

    @Override
    public int count(User user) {
        return userDao.count(user);
    }

    @Override
    public int remove(String userId) throws SQLException {
        return userDao.remove(userId);
    }

    @Override
    public int add(User user) throws SQLException {
        user.setPassword(Md5Util.md5(user.getPassword()));
        return userDao.add(user);
    }

    @Override
    public int modify(User user) throws SQLException {
        user.setPassword(Md5Util.md5(user.getPassword()));
        return userDao.modify(user);
    }
}
